<style>
    .import {
        opacity: 0;
        position: absolute;
        width: 69px;
        height: 38px;
        margin-left: -10px;
    }

    .layui-badge-rim {
        height: 20px;
        border-width: 1px;
        border-style: solid;
        background-color: #eef4f5;
        font: 14px Helvetica Neue, Helvetica, PingFang SC, Tahoma, Arial, sans-serif;
        color: #6e667d;
    }

    table tr {
        height: 40px;
        /* 其他样式 */
    }

    #productPic_path > img {
        max-height: 350px;
        max-width: 700px;
    }

    .material-body {
        display: flex;
        height: 100% !important;
        padding: 0 15px 0 0 !important;
    }

    .material-nav {
        width: 102px;
        background: rgba(0, 0, 0, .01);
    }

    .material-nav .nav-cell {
        padding: 10px 5px 10px 10px;
        cursor: pointer;
        position: relative;
        display: flex;
        align-items: center;
    }

    .material-nav .nav-cell:hover {
        color: #333;
        transition: all .3s;
    }

    .material-nav .nav-cell.nav-active {
        color: #333;
    }

    .material-nav .nav-cell.nav-active::before {
        content: '';
        display: inline-block;
        height: 14px;
        width: 3px;
        background: #1BA70E;
        position: absolute;
        left: 0;
    }

    .material-body .body-left {
        width: 340px;
        height: 100%;
        overflow: hidden;
    }

    .body-left .layui-tab-content {
        height: 100%;
        padding: 0;
        flex: 1;
        border-right: 1px solid #e6e6e6;
    }

    .body-left .layui-tree {
        padding: 5px;
    }

    .body-left .layui-tab {
        height: 100%;
        color: #999;
        display: flex;
        overflow: auto;
    }

    .body-left .layui-tab-title li {
        padding: 0 10px;
    }

    .material-body .body-right {
        width: calc(100% - 355px);
        padding: 15px 0 15px 15px;
    }

    .layui-tree-emptyText {
        padding-top: 5px;
    }

    .body-right xm-select {
        min-height: 32px;
        lin-height: 32px;
    }

    .body-right .layui-table-view {
        margin: 0;
    }

    .layui-card-body .body-right .layui-table {
        position: relative;
        margin: 0;
        height: 15px;
    }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body material-body">
            <!-- 头部操作栏 -->
            <div class="body-left">
                <div class="layui-tab layui-tab-brief">
                    <div class="material-nav" id="materialNav"></div>
                    <div class="layui-tab-content material-tree" id="productTypeTree"></div>
                </div>
            </div>
            <div class="body-right">
                <div class="layui-form lay-header" name="saleWorkOrderProcessingForm">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt" style="width: 80%">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">产品名称</label>
                                        <div class="layui-input-inline">
                                            <input name="skuName" class="layui-input" type="text" placeholder="产品名称"
                                                   autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">产品编码</label>
                                        <div class="layui-input-inline">
                                            <input name="skuCode" class="layui-input" type="text" placeholder="产品编码"
                                                   autocomplete="off"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button class="layui-btn icon-btn" lay-filter="formSubSearchLog" lay-submit
                                                layui-form-keyDownSearch="true"
                                                type="button">查询
                                        </button>
                                        <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows">
                        <div class="lay-btn-box"  style="margin-top: 15px;">
                            <button type="button" id="productDetailBtnCheck" class="layui-btn icon-btn color-green">
                                确认选择现有物料
                            </button>
                            <button type="button" id="productDetailBtnAdd" class="layui-btn icon-btn color-reseda">
                                添加物资信息
                            </button>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table img-table" id="productDetailTable" lay-filter="productDetailTable"></table>
            </div>
        </div>
    </div>
</div>

<style>
    div[lay-id='productDetailTable'] .layui-table-body .layui-table-cell {
        height: 38px;
        line-height: 38px;
    }

    .layui-form-label.w-120 {
        width: 120px;
    }
</style>

<script type="text/html" id="materialNavTemplate">
    {{# layui.each(d, function(index, item){ }}
    <div class="nav-cell {{# if(item.isShow){ }}nav-active{{# } }}" data-value="{{item.labelValue}}"><span>{{item.labelName}}</span>
    </div>
    {{# }); }}
</script>
<!-- 表格操作列 -->
<script type="text/html" id="productDetailTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">编辑</a>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="productDetailForm">
    <form lay-filter="productDetailForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>货品</label>
                <div class="layui-input-inline">
                    <select id="productId" name="productId" lay-filter="productId" required lay-verify="required"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>料号名称</label>
                <div class="layui-input-inline">
                    <input name="skuName" id="skuName" class="layui-input borderNone" type="text" required
                           lay-verify="required"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>料号</label>
                <div class="layui-input-inline">
                    <input name="skuCode" id="skuCode" class="layui-input borderNone" type="text" required
                           lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">国标条码</label>
                <div class="layui-input-inline">
                    <input name="standardBarCode" id="standardBarCode" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">历史品名</label>
                <div class="layui-input-inline">
                    <input name="historyProductName" id="historyProductName" class="layui-input borderNone"
                           type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">历史料号</label>
                <div class="layui-input-inline">
                    <input name="oldSkuCode" id="oldSkuCode" class="layui-input borderNone"
                           type="text"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>规格码</label>
                <div class="layui-input-inline">
                    <input name="skuSpec" id="skuSpec" class="layui-input borderNone" type="text" required
                           lay-verify="required"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>类别性质</label>
                <div class="layui-input-inline">
                    <select id="materialNature" name="materialNature" lay-filter="materialNature" required
                            lay-verify="required"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>所属类别</label>
                <div class="layui-input-inline">
                    <select id="productTypeId" name="productTypeId" lay-filter="productTypeId" required
                            lay-verify="required"
                            class="layui-input borderNone"></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>物料分类</label>
                <div class="layui-input-inline">
                    <select id="productCategoryId" name="productCategoryId" lay-filter="productCategoryId"
                            requiredlay-verify="required"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">品牌</label>
                <div class="layui-input-inline">
                    <select id="brandId" name="brandId" lay-filter="brandId"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">库存计量方式</label>
                <div class="layui-input-inline">
                    <select id="calculateWay" name="calculateWay" lay-filter="calculateWay"
                            class="layui-input borderNone"></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>计量单位</label>
                <div class="layui-input-inline">
                    <select id="unitId" name="unitId" lay-filter="unitId" required lay-verify="required"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>换算率</label>
                <div class="layui-input-inline">
                    <input name="baseUnitRate" id="baseUnitRate" class="layui-input borderNone" type="text" required
                           lay-verify="required"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120"><span style="color: red">*</span>基础单位</label>
                <div class="layui-input-inline">
                    <select id="baseUnit" name="baseUnit" lay-filter="baseUnit" class="layui-input borderNone" required
                            lay-verify="required"></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">计价币种</label>
                <div class="layui-input-inline">
                    <select id="priceCurrency" name="priceCurrency" lay-filter="priceCurrency"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">税率</label>
                <div class="layui-input-inline">
                    <input name="taxRate" id="taxRate" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">是否自产产品</label>
                <div class="layui-input-inline">
                    <select id="selfProductStatus" name="selfProductStatus" lay-filter="selfProductStatus"
                            class="layui-input borderNone"></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">产品性质</label>
                <div class="layui-input-inline">
                    <select id="productNature" name="productNature" lay-filter="productNature"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">是否委外生产</label>
                <div class="layui-input-inline">
                    <select id="outsourceStatus" name="outsourceStatus" lay-filter="outsourceStatus"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">工艺线路</label>
                <div class="layui-input-inline">
                    <select id="productProcessLineId" name="productProcessLineId" lay-filter="productProcessLineId"
                            class="layui-input borderNone"></select>
                </div>
            </div>

        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">成本价</label>
                <div class="layui-input-inline">
                    <input name="costPrice" id="costPrice" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">是否可以销售</label>
                <div class="layui-input-inline">
                    <select id="sellStatus" name="sellStatus" lay-filter="sellStatus"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">销售指导价</label>
                <div class="layui-input-inline">
                    <input name="marketPrice" id="marketPrice" class="layui-input borderNone" type="text"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">长度(mm)</label>
                <div class="layui-input-inline">
                    <input name="length" id="length" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">宽度(mm)</label>
                <div class="layui-input-inline">
                    <input name="width" id="width" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">高度(mm)</label>
                <div class="layui-input-inline">
                    <input name="height" id="height" class="layui-input borderNone" type="text"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">重量(克)</label>
                <div class="layui-input-inline">
                    <input name="weight" id="weight" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">安全库存阈值</label>
                <div class="layui-input-inline">
                    <input name="warningQuantity" id="warningQuantity" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">采购周期(天)</label>
                <div class="layui-input-inline">
                    <input name="purchaseCycle" id="purchaseCycle" class="layui-input borderNone" type="text"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">呆滞时长阈值(天)</label>
                <div class="layui-input-inline">
                    <input name="lethargyThreshold" id="lethargyThreshold" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">质保期(天)</label>
                <div class="layui-input-inline">
                    <input name="warrantyDay" id="warrantyDay" class="layui-input borderNone" type="text"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">折旧时长(月)</label>
                <div class="layui-input-inline">
                    <input name="depreciationTime" id="depreciationTime" class="layui-input borderNone" type="text"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">数据来源</label>
                <div class="layui-input-inline">
                    <select id="dataSource" name="dataSource" lay-filter="dataSource"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">是否一物一码</label>
                <div class="layui-input-inline">
                    <select id="thingCodeStatus" name="thingCodeStatus" lay-filter="thingCodeStatus"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">是否批次管理</label>
                <div class="layui-input-inline">
                    <select id="batchStatus" name="batchStatus" lay-filter="batchStatus"
                            class="layui-input borderNone"></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">是否先进先出</label>
                <div class="layui-input-inline">
                    <select id="inoutStatus" name="inoutStatus" lay-filter="inoutStatus"
                            class="layui-input borderNone"></select>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label w-120">产品属性</label>
                <div class="layui-input-inline">
                    <select id="assemblyNature" name="assemblyNature" lay-filter="assemblyNature"
                            class="layui-input borderNone"></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <div class="right-btn">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="productDetailSubmit" lay-submit>提交</button>
            </div>
        </div>
    </form>
</script>

<!--产品系列列表-->
<script type="text/html" id="productRangeList">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <form class="layui-form toolbar" lay-filter="productRangeList">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">系列名称：</label>
                            <div class="layui-input-inline">
                                <input name="name" class="layui-input" type="text"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn" lay-filter="productRangeListSearchLog" lay-submit
                                    type="button">搜索
                            </button>
                            <button id="productRangeListAddClose" class="layui-btn icon-btn" type="button">确认选择
                            </button>
                        </div>
                    </div>
                </form>

                <!-- 表格 -->
                <table class="layui-table" id="productRangeListTable" lay-filter="productRangeListTable"></table>
            </div>
        </div>
    </div>
</script>
<!-- 数据同步到云端表单弹窗 -->
<script type="text/html" id="syncSkuForm">
    <form lay-filter="synsSkuForm" class="layui-form model-form formBg" style="padding:20px;">
        <div class="layui-card-body">
            <input type="hidden" name="enterpriseCode" id="enterpriseCode" value="">
            <div class="layui-row">
                <div class="layui-col-md4 conentStyle">
                    <div class="conentBg">
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品系列图片:</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="enterpriseItemPic" id="enterpriseItemPic" value=""/>
                                <img src="" style="height: 135px;width: 135px" id="enterpriseItemPicImg"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品系列名称:</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseName" id="enterpriseName" class="layui-input borderNone"
                                       type="text" disabled/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品编码</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductCode" id="enterpriseProductCode"
                                       class="layui-input borderNone" type="text" disabled/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品类型</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductType" id="enterpriseProductType"
                                       class="layui-input borderNone" type="text" disabled/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品分类</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductCategory" id="enterpriseProductCategory"
                                       class="layui-input borderNone" type="text" disabled/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md8 conentStyle">
                    <div class="conentBg">
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品系列图片:</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="pictureSynsInput" id="pictureSynsInput" value=""/>
                                <img src="" style="height: 135px;width: 135px" id="pictureSyns"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品系列名称</label>
                            <div class="layui-input-inline">
                                <input id="platformName" placeholder="请输入平台产品系列" name="platformName"
                                       class="layui-input" lay-search lay-verify="required"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品编码</label>
                            <div class="layui-input-inline">
                                <input name="platformProductCode" id="platformProductCode" class="layui-input"
                                       type="text" placeholder="请输入平台产品系列" disabled/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品类型</label>
                            <div class="layui-input-inline">
                                <input id="platformProductTypeId" type="hidden">
                                <select name="platformProductType" id="platformProductType" class="layui-input"
                                        type="text">
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品分类</label>
                            <div class="layui-input-inline">
                                <select name="platformProductCategory" id="platformProductCategory" class="layui-input"
                                        type="text">
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-card-body">
                <input type="hidden" name="enterpriseCode" id="enterpriseDetailCode" value="">
                <div class="layui-row">
                    <div class="layui-col-md4 conentStyle">
                        <div class="conentBg">
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品图片:</label>
                                <div class="layui-input-inline">
                                    <input type="hidden" name="enterpriseProductDetailPic"
                                           id="enterpriseProductDetailPic" value=""/>
                                    <img src="" style="height: 80px;width: 80px" id="enterpriseProductDetailPicImg"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品名称:</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseDetailName" id="enterpriseDetailName"
                                           class="layui-input borderNone"
                                           type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品编码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailCode" id="enterpriseProductDetailCode"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业品牌</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailBrand" id="enterpriseProductDetailBrand"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品单位</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailUnit" id="enterpriseProductDetailUnit"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品规格码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseSkuSpecValueNames" id="enterpriseSkuSpecValueNames"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品旧规格码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseOldSpecCode" id="enterpriseOldSpecCode"
                                           class="layui-input borderNone" type="text" disabled/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md8 conentStyle">
                        <div class="conentBg">
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品图片:</label>
                                <div class="layui-input-inline">
                                    <input type="hidden" name="platformProductDetailPic" id="platformProductDetailPic"
                                           value=""/>
                                    <img src="" style="height: 80px;width: 80px" id="platformItemPicImg"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品名称</label>
                                <div class="layui-input-inline">
                                    <input name="platformDetailName" id="platformDetailName" class="layui-input"
                                           type="text"
                                           placeholder="请输入产品名称"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品编码</label>
                                <div class="layui-input-inline">
                                    <input name="platformProductDetailCode" id="platformProductDetailCode"
                                           class="layui-input"
                                           type="text" placeholder="请输入产品编码" disabled/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台品牌</label>
                                <div class="layui-input-inline">
                                    <select name="platformProductDetailBrand" id="platformProductDetailBrand"
                                            class="layui-input"
                                            type="text">
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品单位</label>
                                <div class="layui-input-inline">
                                    <select name="platformProductDetailUnit" id="platformProductDetailUnit"
                                            class="layui-input"
                                            type="text">
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品规格码</label>
                                <div class="layui-input-inline">
                                    <input name="platformSkuSpecValueNames" id="platformSkuSpecValueNames"
                                           class="layui-input borderNone" type="text"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品旧规格码</label>
                                <div class="layui-input-inline">
                                    <input name="platformOldSpecCode" id="platformOldSpecCode"
                                           class="layui-input borderNone" type="text"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" lay-filter="syncSubmit" lay-submit>同步</button>
                </div>
            </div>
        </div>
    </form>
</script>
<!-- 产品系列弹窗 -->
<script type="text/html" id="productForm">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form lay-header">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">产品编号：</label>
                                        <div class="layui-input-inline">
                                            <input name="productCode" class="layui-input" type="text"
                                                   placeholder="请输入产品编号"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">产品名称：</label>
                                        <div class="layui-input-inline">
                                            <input name="name" class="layui-input" type="text"
                                                   placeholder="请产品名称"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog"
                                                lay-submit>查询
                                        </button>
                                        <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>
                                            重置
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows">
                        <div class="lay-btn-box">
                            <div class="lay-btn-lt">
                            </div>
                            <div class="lay-btn-rt">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="productTable" lay-filter="productTable"></table>

                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" lay-filter="productSubmit" lay-submit>提交</button>
                </div>
            </div>
        </div>
    </div>
</script>

<!--单独修改图片-->
<!--imgModifyForm-->
<script type="text/html" id="imgModifyForm">
    <form lay-filter="imgModifyForm" class="layui-form model-form"
          style="padding: 5px 30px 0 30px;height: calc(100% - 5px);overflow: hidden;">
        <div class="open-details-box" style="height: calc(100% - 75px);">
            <div class="layui-row table-bor " style="margin-top: 15px;">
                <div class="layui-form-item">
                    <div id="productPic_path" class="uploadImgStyle"></div>
                    <div id="productPicBtn" class="layui-btn" style="float: left;">
                        <i class="layui-icon">&#xe681;</i>上传图片
                    </div>
                    <input name="productPic" type="hidden" class="layui-input" lay-verify="" id="productPic"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="imgModifyFormSubmit" lay-submit type="button">保存</button>
        </div>
    </form>
</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'upload', 'tree', 'laytpl'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laytpl = layui.laytpl;
        var syncProductName = "";
        var syncProductId = 0;


        let bomSkuData = admin.getTempData("bomSkuData");

        $("body").delegate(".checkImg", "click", function () {
            admin.previewImg(".checkImg")
        });

        // 获取类别性质
        admin.req('enterprise/dict/admin/dictLabel/list', {
            dictType: 'sys_product_type_nature',
            requestType: 'research'
        }, res => {
            if (res.code == 200 && res.data.length > 0) {
                res.data.forEach(item => {
                    item.isShow = false
                })
                res.data[0].isShow = true;
                getProductType(res.data[0].labelValue)
                laytpl(materialNavTemplate.innerHTML).render(res.data, function (html) {
                    $('#materialNav').html(html);
                    $('#materialNav .nav-cell').click(function () {
                        let val = $(this).data('value');
                        $(this).addClass("nav-active").siblings().removeClass("nav-active");
                        getProductType(val)
                    })
                });
            }
        });

        //物料类型
        function getProductType(materialNature) {
            admin.req('enterprise/product/admin/productType/list', {
                enterprise: 0,
                limit: 99999,
                materialNature: materialNature
            }, res => {
                if (res.code == 200) {
                    let treeList = res.data.filter(item => {
                        return item.isDeleted
                    })
                    initTree(treeList)
                    // loadSelectHtml(res.data, '请选择物料类型', 'productTypeId', 'name');
                } else {
                    // loadSelectHtml([], '请选择物料类型', 'productTypeId', 'name')
                }
            });
        }

        function initTree(data) {
            layui.tree.render({
                elem: '#productTypeTree' //传入元素选择器
                , data: formatToTree(data, "-1"),
                click: function (obj) {
                    insTb.reload({where: {productTypeId: obj.data.id}, page: {curr: 1}}, 'data');
                }
            });
        }

        function formatToTree(ary, pid, pidName = 'parentId') {
            return ary
                .filter((item) => item[pidName] === pid)
                .map((item) => {
                    // 通过父节点ID递归查询所有子节点
                    item.children = formatToTree(ary, item.id);
                    item.label = item.name;
                    // item.spread = true
                    return item;
                });
        }

        form.render("select");
        // 渲染表格
        var insTb = table.render({
            elem: '#productDetailTable',
            url: config.base + 'enterprise/product/admin/productDetailWMS/list',
            where: {categoryType: 'production',excludeId:bomSkuData.productDetailId},
            toolbar: true,
            defaultToolbar: ["filter"],
            page: true,
            limit: 10,
            limits: [10, 20, 30, 40, 50, 60, 70, 80],
            cellMinWidth: 100,
            cols: [[
                {type: 'checkbox', fixed: 'left'},
                {type: 'numbers', title: '序号', align: 'center', width: 60}
                , {
                    field: 'skuName', align: 'center', width: 180,
                    templet: function (d) {
                        return '<span class="layui-badge-rim">' + d.skuName + '</span>';
                    }, title: '料号名称',
                    event: 'imgClick'
                }
                , {field: 'skuCode', align: 'center', title: '料号'}
                , {field: 'skuSpec', align: 'center', title: '规格码'}
                , {field: 'materialNatureName', align: 'center', title: '类别性质',}
                , {field: 'productTypeName', align: 'center', title: '所属类别'}
                , {field: 'calculateWayName', align: 'center', title: '计量单位'}
                , {field: 'baseUnitRate', align: 'center', title: '换算率'}
                // , {field: 'unitName', align: 'center', title: '基础单位'}
                , {align: 'center', toolbar: '#productDetailTableBar', title: '操作', width: 100, fixed: 'right'}
            ]],
        });

        // 工具条点击事件
        table.on('tool(productDetailTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') { //修改
                showEditModel(data);
            } else if (obj.event === 'imgClick') {
                imgModify(data);
            } else if (obj.event === 'del') { // 删除
                doDelete(obj);
            } else if (obj.event === 'syncSku') { // 同步
                syncSku(obj);
            }
        });

        //监听排序
        table.on('sort(productDetailTable)', function (obj) {
            table.reload('productDetailTable', {
                initSort: obj
                , where: {
                    sort: obj.field
                    , order: obj.type
                }
            });
        });

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}}, 'data');
        });

        // 重置搜索
        form.on('submit(resets)', function (data) {
            $(".lay-header").find('select').val("");
            $(".lay-header").find('input').val("");
            let field = data.field;
            for (let key in field) {
                field[key] = ''
            }
            insTb.reload({where: field, page: {curr: 1}}, 'data');
        });

        function imgModify(data) {
            admin.open({
                type: 1,
                area: ["900px", "500px"],
                offset: '65px',
                title: '修改图片',
                content: $('#imgModifyForm').html(),
                success: function () {
                    form.val('imgModifyForm', data);
                    $('#productPic_path').html('<img class="checkImg" style="max-height:350px; max-width: 700px" src="' + data.productPic + '"/>');
                    $('#productPicBtn').click(uploadImg('productPicBtn', 'productPic_path', 'productPic'));
                    form.on('submit(imgModifyFormSubmit)', function (d) {
                        layer.load(2);
                        d.field.id = data.id;
                        d.field.image = d.field.productPic;
                        admin.req('enterprise/product/admin/productDetail/update', JSON.stringify(d.field), function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('productDetailTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'PUT', true, 'application/json; charset=utf-8');
                        return false;
                    })
                }
            })
        }

        // 添加按钮点击事件
        $('#productDetailBtnAdd').click(function () {
            showEditModel();
        });


        // 确认选择现有物料的点击事件
        $('#productDetailBtnCheck').click(function () {
            let checkRows = table.checkStatus('productDetailTable').data;
            let parmas = {};
            parmas.parentId = bomSkuData.productDetailId;
            parmas.bomId = bomSkuData.bomId;
            parmas.flag = bomSkuData.flag;
            parmas.parentCode = bomSkuData.skuCode;
            if (checkRows.length == 0) {
                layer.msg('请选择物料', {icon: 2});
            } else {
                let names='';
                let childrenData = [];
                checkRows.forEach(item=>{
                    names+=item.skuCode +','
                    let children = {};
                    children.skuCode = item.skuCode;
                    children.skuId = item.id;
                    children.skuParentId = bomSkuData.productDetailId;
                    if (item.assemblyNature === '3'){
                        children.isFinal = true;
                    }else{
                        children.isFinal = false;
                    }
                    childrenData.push(children);
                })
                parmas.childrenData = childrenData;
                layer.confirm('确认要将？'+"["+names+"]添加到"+bomSkuData.skuCode+"的子件中吗？",{
                    offset: '65px',
                    skin: 'layui-layer-admin'
                }, function (i) {
                    layer.close(i);
                    layer.load(2);
                    //添加bom子件信息
                    admin.req('enterprise/res/admin/planning/proBom/addBom',JSON.stringify(parmas), function (res) {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1});
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'POST',true,'application/json; charset=utf-8');
                    // layer.close(parentData.zindex); // 关闭当前弹窗
                    let index = $('#productDetailBtnCheck').closest('.layui-layer').attr('times')
                    layer.close(index);
                })
            }
        });

        // 显示编辑弹窗
        function showEditModel(data) {
            admin.open({
                type: 1,
                area: '1200px',
                offset: '65px',
                title: data ? '编辑产品明细' : '添加产品明细',
                content: $('#productDetailForm').html(),
                success: function () {
                    if (data) {
                        //获取产品明细
                        admin.reqSync('enterprise/product/admin/productDetailWMS/get?productDetailId=' + data.id, {}, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                //货品
                                admin.initDataSelect("enterprise/product/admin/product/list", {limit: 9999}, "productId", res.data.productId, "货品", null, null);
                                //物料类别性质
                                admin.getDictList("materialNature", "sys_product_type_nature", res.data.materialNature, "物料类别性质");
                                //所属类别
                                admin.initDataSelect("enterprise/product/admin/productType/list", {limit: 9999}, "productTypeId", res.data.productTypeId, "所属类别", null, null);
                                //物料分类
                                admin.initDataSelect("enterprise/product/admin/productCategory/list", {limit: 9999}, "productCategoryId", res.data.productCategoryId, "物料分类", null, null);
                                //品牌
                                admin.initDataSelect("enterprise/product/admin/productBrand/list", {limit: 9999}, "brandId", res.data.brandId, "品牌", null, null);
                                //库存计量方式
                                admin.getDictList("calculateWay", "sys_product_detail_calculate_way", res.data.calculateWay, "库存计量方式");
                                //计量单位
                                admin.getDictList("unitId", "sys_product_detail_calculate_unit", res.data.unitId, "计量单位");
                                //基础单位
                                admin.getDictList("baseUnit", "sys_product_detail_base_unit", res.data.baseUnit, "基础单位");
                                //计价币种
                                admin.getDictList("priceCurrency", "sys_product_detail_price_currency", res.data.priceCurrency, "计价币种");
                                //是否自产产品
                                admin.getDictList("selfProductStatus", "sys_yes_no", res.data.selfProductStatus, "是否自产产品");
                                //产品性质

                                admin.getDictList("productNature", "product_nature", res.data.productNature, "产品性质");
                                //是否委外生产
                                admin.getDictList("outsourceStatus", "sys_yes_no", res.data.outsourceStatus, "是否委外生产");
                                //工艺线路
                                admin.initDataSelect("enterprise/product/admin/processLineTemplate/list", {limit: 99999}, "productProcessLineId", res.data.productProcessLineId, "工艺线路", null, null);
                                //是否可以销售
                                admin.getDictList("sellStatus", "sys_yes_no", res.data.sellStatus, "是否可以销售");
                                //数据来源
                                admin.getDictList("dataSource", "sys_product_detail_data_source", res.data.dataSource, "数据来源");
                                //是否一物一码
                                admin.getDictList("thingCodeStatus", "sys_yes_no", res.data.thingCodeStatus, "是否一物一码");
                                //是否批次管理
                                admin.getDictList("batchStatus", "sys_yes_no", res.data.batchStatus, "是否批次管理");
                                //是否先进先出
                                admin.getDictList("inoutStatus", "sys_yes_no", res.data.inoutStatus, "是否先进先出");
                                //产品属性
                                admin.getDictList("assemblyNature", "product_assembly_nature", res.data.assemblyNature, "产品属性");
                                form.val('productDetailForm', res.data);
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'GET');
                    } else {
                        //货品
                        admin.initDataSelect("enterprise/product/admin/product/list", {limit: 9999}, "productId", null, "货品", null, null);
                        //物料类别性质
                        admin.getDictList("materialNature", "sys_product_type_nature", null, "物料类别性质");
                        //所属类别
                        admin.initDataSelect("enterprise/product/admin/productType/list", {limit: 9999}, "productTypeId", null, "所属类别", null, null);
                        //物料分类
                        admin.initDataSelect("enterprise/product/admin/productCategory/list", {limit: 9999}, "productCategoryId", null, "物料分类", null, null);
                        //品牌
                        admin.initDataSelect("enterprise/product/admin/productBrand/list", {limit: 9999}, "brandId", null, "品牌", null, null);
                        //库存计量方式
                        admin.getDictList("calculateWay", "sys_product_detail_calculate_way", null, "库存计量方式");
                        //计量单位
                        admin.getDictList("unitId", "sys_product_detail_calculate_unit", null, "计量单位");
                        //基础单位
                        admin.getDictList("baseUnit", "sys_product_detail_base_unit", null, "基础单位");
                        //计价币种
                        admin.getDictList("priceCurrency", "sys_product_detail_price_currency", null, "计价币种");
                        //是否自产产品
                        admin.getDictList("selfProductStatus", "sys_yes_no", null, "是否自产产品");
                        //产品性质
                        admin.getDictList("productNature", "product_nature", null, "产品性质");
                        //是否委外生产
                        admin.getDictList("outsourceStatus", "sys_yes_no", null, "是否委外生产");
                        //工艺线路
                        admin.initDataSelect("enterprise/product/admin/processLineTemplate/list", {limit: 99999}, "productProcessLineId", null, "工艺线路", null, null);
                        //是否可以销售
                        admin.getDictList("sellStatus", "sys_yes_no", null, "是否可以销售");
                        //数据来源
                        admin.getDictList("dataSource", "sys_product_detail_data_source", null, "数据来源");
                        //是否一物一码
                        admin.getDictList("thingCodeStatus", "sys_yes_no", null, "是否一物一码");
                        //是否批次管理
                        admin.getDictList("batchStatus", "sys_yes_no", null, "是否批次管理");
                        //是否先进先出
                        admin.getDictList("inoutStatus", "sys_yes_no", null, "是否先进先出");
                        //产品属性
                        admin.getDictList("assemblyNature", "product_assembly_nature", null, "产品属性");
                    }

                    // 表单提交事件
                    form.on('submit(productDetailSubmit)', function (d) {
                        admin.req(data ? 'enterprise/product/admin/productDetail/update' : 'enterprise/product/admin/productDetail/add', JSON.stringify(d.field), function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('productDetailTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, data ? 'PUT' : 'POST', true, 'application/json; charset=utf-8');
                        return false;
                    });

                }
            });
        }

        //查询企业信息
        var enterpriseInfo;
        admin.req('enterprise/system/admin/enterpricceId/getEnterpricceIdVO', {}, function (res) {
            enterpriseInfo = res.data;
        }, 'get', false);

        function syncSku(obj) {
            admin.open({
                type: 1,
                area: ['80%', '80%'],
                offset: '65px',
                title: '同步至云端',
                content: $('#syncSkuForm').html(),
                success: function () {
                    var sync = false;
                    var productData = null;
                    //获取企业产品
                    admin.reqSync('enterprise/product/admin/productDetailWMS/syncList?skuCode=' + obj.data.skuCode, {}, function (res) {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            $("#enterpriseItemPicImg").attr("src", res.data.picture);
                            $("#enterpriseName").val(res.data.name)
                            $("#enterpriseProductCode").val(res.data.productCode)
                            $("#enterpriseProductType").val(res.data.productType)
                            $("#enterpriseProductCategory").val(res.data.productCategory)
                            $("#enterpriseProductCategoryExt").val(res.data.enterpriseProductCategoryExt)
                            $("#enterpriseDetailName").val(res.data.productDetail.productName)
                            $("#enterpriseProductDetailPicImg").attr("src", res.data.productDetail.productPic)
                            $("#enterpriseProductDetailCode").val(res.data.productDetail.skuCode)
                            $("#enterpriseProductDetailBrand").val(res.data.productDetail.brandName)
                            $("#enterpriseProductDetailUnit").val(res.data.productDetail.unitName)
                            $("#enterpriseSkuSpecValueNames").val(res.data.productDetail.skuSpecValueNames)
                            $("#enterpriseOldSpecCode").val(res.data.productDetail.oldSpecCode)


                            $("#pictureSyns").attr("src", res.data.picture);
                            $("#platformProductCode").val(enterpriseInfo.enterpriseCode + "_" + res.data.productCode)
                            $("#platformName").val(res.data.name)
                            $("#platformItemPicImg").attr("src", res.data.productDetail.productPic)
                            $("#platformProductDetailCode").val(enterpriseInfo.enterpriseCode + "_" + res.data.productDetail.skuCode)
                            $("#platformDetailName").val(res.data.productDetail.productName)
                            $("#platformSkuSpecValueNames").val(res.data.productDetail.skuSpecValueNames)
                            $("#platformOldSpecCode").val(res.data.productDetail.oldSpecCode)
                            productData = res.data
                            //form.render();
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'GET');
                    //获取平台产品类型
                    admin.req('enterprise/product/admin/productType/platformProductTypeList', {}, function (res) {
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '平台产品类型', 'platformProductType', 1, 'synsSkuForm')
                        } else {
                            loadSelectHtml([], '平台产品类型', 'platformProductType', 1, 'synsSkuForm')
                        }
                    }, 'GET')

                    //获取平台产品分类
                    admin.req('enterprise/product/admin/productCategory/platformProductCategoryList', {}, function (res) {
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '平台产品分类', 'platformProductCategory', 1, 'synsSkuForm')
                        } else {
                            loadSelectHtml([], '平台产品分类', 'platformProductCategory', 1, 'synsSkuForm')
                        }
                    }, 'GET')

                    //获取平台品牌
                    admin.req('enterprise/product/admin/productBrand/platformList', {}, function (res) {
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '平台品牌', 'platformProductDetailBrand', 1, 'synsSkuForm')
                        } else {
                            loadSelectHtml([], '平台品牌', 'platformProductDetailBrand', 1, 'synsSkuForm')
                        }
                    }, 'GET')

                    //获取平台产品单位
                    admin.req('enterprise/product/admin/productUnit/platformProductUnitList', {}, function (res) {
                        if (res.code === 200) {
                            loadSelectHtml(res.data, '平台产品分类', 'platformProductDetailUnit', 1, 'synsSkuForm')
                        } else {
                            loadSelectHtml([], '平台产品分类', 'platformProductDetailUnit', 1, 'synsSkuForm')
                        }
                    }, 'GET')

                    form.on('submit(syncSubmit)', function (data) {
                        productData.picture = $("#pictureSyns").val();
                        productData.productCode = $("#platformProductCode").val()
                        productData.name = $("#platformName").val()
                        productData.productTypeId = $("#platformProductType").val()
                        productData.productCategoryId = $("#platformProductCategory").val()
                        productData.productDetail.productPic = $("#platformItemPicImg").val()
                        productData.productDetail.skuCode = $("#platformProductDetailCode").val()
                        productData.productDetail.skuName = $("#platformDetailName").val()
                        productData.productDetail.skuSpecValueNames = $("#platformSkuSpecValueNames").val()
                        productData.productDetail.oldSpecCode = $("#platformOldSpecCode").val()
                        productData.productDetail.brandId = $("#platformProductDetailBrand").val()
                        productData.productDetail.unitId = $("#platformProductDetailUnit").val()
                        admin.req('enterprise/product/admin/productDetailWMS/syncProduct', JSON.stringify(productData), function (res) {
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'POST', true, 'application/json; charset=utf-8');
                        /* layer.msg("不允许非法同步", {icon: 2});*/
                        return false
                    });
                }
            });
        }

        // 删除
        function doDelete(obj) {
            layer.confirm('确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprise/product/admin/productDetail/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
            });
        }

        // 上传文件
        /*
        * _elem: 上传按钮的名字,
        * pathId: 显示图片容器的名字,
        * inputId: 提交文件路径元素的名字,
        * isMultiple: 是不是多文件(单文件为空或者false,多文件true)
        *
        * */
        function uploadImg(_elem, pathId, inputId, isMultiple) {
            upload.render({
                elem: '#' + _elem
                , url: config.upload_url + 'uploadFile'
                , data: {}
                , accept: 'file'
                , exts: 'jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx'
                , headers: {Authorization: 'Bearer ' + config.getToken()}
                , done: function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg || "上传成功", {icon: 1});
                        let imagUrl = res.data.url;
                        if (isMultiple == true) {
                            $('#' + pathId).append('<img src="' + imagUrl + '"/>');
                            $('#' + inputId).val(imagUrl);
                        } else {
                            $('#' + pathId).html('<img src="' + imagUrl + '"/>');
                            $('#' + inputId).val(imagUrl);
                        }
                    } else if (res.code == 502) {
                        return location.replace('admin/login.html');
                    } else {
                        layer.msg(res.msg || "上传失败", {icon: 2});
                    }
                }
            });
        }


        // 渲染下拉选项
        function loadSelectHtml(data, tips, htmltarget, type, formName) {
            let html = ' <option value>' + tips + '</option>';
            if (!data || data == null) {
                return;
            }
            for (let i = 0; i < data.length; i++) {
                if (type == 1) {
                    html += `<option value='${data[i].id}'>${data[i].name}</option>`;
                }
            }
            $("form[lay-filter='" + formName + "'] select[name='" + htmltarget + "']").html(html);
            form.render('select');
        }

    })
    ;
</script>